﻿using System;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
using System.IO;
using System.Windows.Threading;
using System.Threading;
using System.Data;
using System.Xml.Serialization;

namespace MediaPlayer_Beta
{
	/// <summary>
	/// Logique d'interaction pour NamePlaylistControler.xaml
	/// </summary>
    /// 

    

	public partial class NamePlaylistControler : Window
	{
        public List<playlist> playlists;
        public List<Ressource> current;

		public NamePlaylistControler(List<Ressource> cur, List<playlist> pls)
		{
            
			this.InitializeComponent();
            current = cur;
            playlists = pls;
            
		}

        private void ok_Click(object sender, RoutedEventArgs e)
        {
            playlist pl = new playlist();
            pl.name = TB.Text;
            pl.pl = current;
            playlists.Add(pl);
            XmlSerializer x = new XmlSerializer(typeof(List<playlist>));
            using (StreamWriter rd = new StreamWriter("Playlist.xml"))
            {
                x.Serialize(rd, playlists);
            }
            this.Close();
        }

        private void cancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
	}
}